package com.example.javatwo.service.xs.lyh;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.javatwo.mapper.xs.lyh.IAllocateDao;
import com.example.javatwo.pojo.xs.lyh.allocate;
import com.example.javatwo.pojo.xs.lyh.pageBean;
import com.example.javatwo.service.cg.dwh.ZiDongdanhao;

@Service
public class AllocateBizImpl {
	
	@Autowired
	public IAllocateDao alldao;

	
	public pageBean queryAllocateInfo(Map<String, Object> s){
		Integer page = Integer.valueOf(String.valueOf(s.get("page")));
		List<allocate> allo = this.alldao.queryAllocateInfo(page);
		Integer count =this.alldao.queryCountlyh();
		pageBean pb = new pageBean(count, 1, page, allo);
		return pb;
	}
	
	public void insertAllocate(allocate allo){
		if(this.alldao.queryCountlyh()!=0){
			this.alldao.delAllo(allo.getMoveNo());
		}
		this.alldao.insertAllocate(allo);
	}
	
	public void updateAllocate(allocate allo){
		this.alldao.updateAllocate(allo);
	}
	
	
	/**
	 * 调出仓库：仓库数量减少
	 * @param shuliang
	 * @param wareHouseID
	 */
	public void updateDepotDetaillyh(Integer shuliang,Integer wareHouseID){
		this.alldao.updateDepotDetaillyh(shuliang, wareHouseID);
	}
	
	/**
	 * 调入仓库：仓库数量增加
	 * @param shuliang
	 * @param wareHouseID
	 */
	public void updateDepotDetaillyh1(Integer shuliang,Integer wareHouseID){
		this.alldao.updateDepotDetaillyh1(shuliang, wareHouseID);
	}
	
	/**
	 * 做出审核-反审核
	 * @param moveNom
	 * @param isShenHe
	 */
	public void updateShenHeStuats(String moveNo,String isShenHe){
		this.alldao.updateShenHeStuats(moveNo, isShenHe);
	}
	
	/**
	 * 自动单号
	 * @param moveNo
	 * @return
	 */
	public String queryMaxlyh(String moveNo){
		String moveNos = moveNo.replace("-", ""); 
		String danhao = this.alldao.queryMaxlyh(moveNos);
		String da = ZiDongdanhao.Danhaoshengcheng(danhao);
		return da;
	}
}
